package com.blueberry.commbank.controller;

import com.blueberry.commbank.application.TransferService;
import com.blueberry.commbank.application.dto.TransferRequestDTO;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/accounts")
@Validated
public class AccountController {
    @Autowired
    private TransferService transferService;

    @PostMapping("/account:transfer")
    public ResponseEntity<String> transfer(
            @RequestBody @Valid TransferRequestDTO transferRequestDTO) {
        transferService.transfer(transferRequestDTO);
        return ResponseEntity.ok().body("Done");
    }
}
